library(knitr)
hook_output = knit_hooks$get('output')
knit_hooks$set(output = function(x, options) {
# this hook is used only when the linewidth option is not NULL
if (!is.null(n <- options$linewidth)) {
x = xfun::split_lines(x)
# any lines wider than n should be wrapped
if (any(nchar(x) > n)) x = strwrap(x, width = n)
x = paste(x, collapse = '\n')
}
hook_output(x, options)
})2 Troubleshooting
In this document I record errors that I encounter and how I resolved them. Solutions will typically be from Googling, relevant links will be provided.
3 Rmarkdown knitting PDF
Error message:
tlmgr update --all --self
fmtutil [ERROR]: format directory not writable: /usr/local/texlive/2019/texmf-var/web2c
tlmgr: package repository https://mirror.clientvps.com/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr install: package already present: l3kernel
! LaTeX Error: Mismatched LaTeX support files detected.
(LaTeX) Loading 'expl3.sty' aborted!
(LaTeX)
(LaTeX) The L3 programming layer in the LaTeX format
(LaTeX) is dated 2023-02-01, but in your TeX tree the files require
(LaTeX) at least 2023-02-02.
Error: LaTeX failed to compile 03-exp123.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See 03-exp123.log for more info.
In addition: Warning messages:
1: Removed 156 rows containing non-finite values (stat_ydensity).
2: Removed 156 rows containing non-finite values (stat_boxplot).
3: Removed 156 rows containing non-finite values (stat_summary).
4: Removed 156 rows containing non-finite values (stat_summary).
5: Removed 156 rows containing non-finite values (stat_ydensity).
6: Removed 156 rows containing non-finite values (stat_boxplot).
7: Removed 156 rows containing non-finite values (stat_summary).
8: Removed 156 rows containing non-finite values (stat_summary).
Execution haltedIn the Terminal, I type
kpsewhich --all --engine=pdftex pdflatex.fmtAnd get:
(base) administrators-MacBook-3:Lifetime Project danielapalleschi$ kpsewhich --all --engine=pdftex pdflatex.fmt
/usr/local/texlive/2019/texmf-var/web2c/pdftex/pdflatex.fmtSo my pdftex version is from 2019 or soemthing.
In the Terminal, I typed:
sudo fmtutil-sys --allAnd entered my laptop’s administrator Password when prompted (it won’t show that you’re typing, but just type the password and hit Enter). Then Terminal was running for a couple of minutes, and ended with the output:
Transcript written on mex.log.
fmtutil [INFO]: /usr/local/texlive/2019/texmf-var/web2c/pdftex/mex.fmt installed.
fmtutil [INFO]: Disabled formats: 6
fmtutil [INFO]: Successfully rebuilt formats: 45
fmtutil [INFO]: Total formats: 51
fmtutil [INFO]: exiting with status 0When I went to knit a PDF I still got the same errors.
Then I ran
fmtutil-user --allNo password required, it ran again for a few minutes. At the end, I got
Transcript written on mf.log.
fmtutil [INFO]: /Users/danielapalleschi/Library/texlive/2019/texmf-var/web2c/metafont/mf.base installed.
fmtutil [INFO]: Disabled formats: 6
fmtutil [INFO]: Successfully rebuilt formats: 45
fmtutil [INFO]: Total formats: 51
fmtutil [INFO]: exiting with status 03.1 Solution
In the end I went into my Time Machine (external harddrive) to a point right before this problem started happening, and restored the ‘Macintosh HD/Library’ folder, because presumably something happened to the TexLive file or something in there. That solved the problem.
4 Rmarkdown and kableExtra with R version 4.3
5 Stargazer
5.1 Solution
6 31.08.2022: updated to R version 4.2.1 (2022-06-23), now stargazer won’t compile tables where model names are too long
7 Solution: discussed here https://www.reddit.com/r/rstats/comments/ucmtdn/issue_with_stargazer_package_after_update_to_r_420/
8 code below from linked solution https://gist.github.com/alexeyknorre/b0780836f4cec04d41a863a683f91b53
8.1 Quick fix for stargazer <= 5.2.3 is.na() issue with long model names in R >= 4.2
9 Unload stargazer if loaded
detach(“package:stargazer”,unload=T) # Delete it remove.packages(“stargazer”) # Download the source download.file(“https://cran.r-project.org/src/contrib/stargazer_5.2.3.tar.gz”, destfile = “stargazer_5.2.3.tar.gz”) # Unpack untar(“stargazer_5.2.3.tar.gz”) # Read the sourcefile with .inside.bracket fun stargazer_src <- readLines(“stargazer/R/stargazer-internal.R”) # Move the length check 5 lines up so it precedes is.na(.) stargazer_src[1990] <- stargazer_src[1995] stargazer_src[1995] <- “” # Save back writeLines(stargazer_src, con=“stargazer/R/stargazer-internal.R”) # Compile and install the patched package install.packages(“stargazer”, repos = NULL, type=“source”) ### FROM NOW ON: shorter model names for stargazer
`